<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>切换图片</title>
    </head>
    <body>
        <img id="pic" src="images/1.jpg"/>
        <input type="button" value="下一张" onclick="next()"/>
        <input type="button" value="上一张" onclick="previous()"/>
        <script type="text/javascript">
            var a = 1;
            function next(){
                a=a+1;
                pic.src="images/" + a + ".jpg";
            }
            function previous(){
                a=a-1;
                pic.src="images/" + a + ".jpg";
            }
        </script>




    </body>
</html>